package com.mysql.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DBUtils {

    public static Connection getConnection() throws Exception {
        String url="jdbc:mysql://localhost:3306/bilibili?user=root&password=&useUnicode=true&characterEncoding=GB2312";

        Class.forName("com.mysql.jdbc.Driver");

        Connection conn= DriverManager.getConnection(url);
        return conn;
    }

    public static void closeConnection(Connection conn, Statement statement) throws SQLException {

        if (statement!=null){
            statement.close();
        }

        if (conn!=null){
            conn.close();
        }

    }
}
